#include<bits/stdc++.h>

using namespace std;
#define ll long long
#define MOD 1000000007

int main(){
    ll t;
    cin>>t;
    while(t--){
        ll n,k;
        cin>>n>>k;
        vector<ll>arr(n);
        set<ll>numbers;
        for(int i = 0;i<n;i++){
            cin>>arr[i];
        }
        ll right = n+2;
        ll left = 0;
        ll ans = 0;
        while(left<=right){
            numbers.clear();
            ll currK = 0;
            ll mid = (left+right)/2;
            //cout<<mid<<" Value"<<"\n";
            for(int i = 0;i<n;i++){
                if(arr[i]<mid){
                    numbers.insert(arr[i]);
                }
                if(numbers.size() == mid){
                    numbers.clear();
                    currK++;
                }
            }
            if(currK>=k){
                //cout<<mid<<" here \n";
                ans = mid;
                left = mid+1;
            } else {
                right = mid - 1;
            }
        }
        cout<<ans<<"\n";

    }
    return 0;
}